package com.zhao.concreteAggregate;

import com.zhao.User;
import com.zhao.aggregate.UserAggregate;
import com.zhao.concreteIterator.UserIteratorImpl;
import com.zhao.iterator.UserIterator;

import java.util.ArrayList;
import java.util.List;

public class UserAggregateImpl implements UserAggregate {

    private List<User> users = new ArrayList<>();

    @Override
    public void addUser(User user) {
        users.add(user);
    }

    @Override
    public void removeUser(int index) {
        users.remove(index);
    }

    @Override
    public User getUser(int index) {
        return users.get(index);
    }

    @Override
    public UserIterator getUserIterator() {
        return new UserIteratorImpl(users);
    }
}
